<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Vue</title>
</head>
<body>
  <div id="app" style="color:red;font-size:18px">
    <p>{{age}}</p>
    <p>{{name}}</p>
    <p>{{allName}}</p>
  </div>
  <script src='/dist/umd/vue.js'></script>
  <script>
    let vm = new Vue({
      el: '#app',
      data(){
        return {
          name: 'gucan',
          age: [[1,2,3]],
          age2: 18
        }
      },
      computed:{
        //computed依赖的值不变就不会重新执行
        //computed变量可用于模版的渲染
        allName(){
          console.log('testcomputed')
          return this.name + '-' + this.age2;
        }
      },
      watch: {
       name:[{
         handler: 'handler',
         sync:true
       }]
      },
      methods: {
        handler(newVal,oldVal){
          console.log(newVal,oldVal,'watcherupdate')
        }
      },
      beforeCreate(){
         console.log('user',this.age)
      },
      created(){
         console.log(this.$el ,'created');
      },
      beforeMount(){
         console.log(this.$el,'beforemount')
      },
      mounted(){
        console.log(this.$el,'mounted')
      },
    })
      console.log(vm.allName)
      console.log(vm.allName)
      setTimeout(()=>{
        vm.name = 'xxxx';
        console.log(vm.allName)
      },1000)
      // vm.age.push(1);
      // vm.age.push(2);
      // vm.age.push(3);
      // vm.age.push(4)
      // vm.$nextTick(()=>{
      //     console.log(vm.$el.innerHTML,'inner');
      // // })
      // vm.name = 'newgugug'
      // vm.name = 'gugu2q22'
  </script>
</body>
</html>
